1. Field
The described embodiments relate to computer systems. More specifically, the described embodiments relate to techniques for allocating checkpoints in speculative processors.
2. Related Art
Some modern microprocessors support speculatively executing program code. This generally involves executing instructions speculatively while preserving a pre-speculation architectural state of the processor. This enables the processor to discard speculative results and return to the pre-speculation architectural state if certain conditions occur during speculative execution (e.g., encountering an error/trap, a coherence violation, unavailability of processor hardware resources, executing certain types of instructions, etc.).
Some processors that support speculative execution use checkpoints to preserve the pre-speculation architectural state. These processors typically include mechanisms to generate checkpoints while speculatively executing instructions. For example, some processors include copies of one or more processor structures (register files, state registers, etc.) in which the pre-speculation architectural state is preserved during speculative execution.
Some processors that support speculative execution further provide processor structures to support multiple checkpoints. These processors can include multiple copies of the processor structures for generating checkpoints. These processors can use each of the available checkpoints to preserve the architectural state of the processor at a given point in time. In these processors, one or more checkpoints can be in use simultaneously.
When the checkpoints in a multiple-checkpoint processor are generated at appropriate times, the performance of the processor can be significantly improved. However, determining when to generate a checkpoint to maximize performance gains can be unclear, and generating checkpoints at incorrect times can significantly reduce the performance improvements. For example, when checkpoints are generated too often, the processor may run out of checkpoints and will be unable to generate subsequent checkpoints (until a checkpoint is cleared). Alternatively, if checkpoints are not generated often enough, when the speculative execution fails, the processor may be forced to re-execute a large number of instructions.